<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">

    </div>
    
</body>
<script src="../react@17.js"></script>
<script src="../react-dom@17.js"></script>
<script src="../babel.js"></script>
<script type="text/babel">
    let userList = [
        {
            name:"张三",
            age:18
        },{
            name:"李四",
            age:20,
        },{
            name:"王五",
            age:30
        }
    ]
    function clickHander(){
        alert("咋啦")
    }
    let showName = (e,name,age)=>{
        e.target.innerText = name;
        alert(name+age)
    }
    let div = (
        <div>
            <button onClick={(e)=>{
                console.log(e)
                alert("点你一下能咋地")
            }}>点我一下你试试</button>    
            <button onClick={clickHander}>再点一下你试试</button>
            <button onClick={()=>clickHander()}>点点</button>
            {
                /* 事件传参？ */
            }
            <ol>
                {
                    userList.map((item,index)=>{
                        return <li key={index}>{item.name}----{item.age}---
                            <button onClick={()=>{
                                alert(item.name+item.age)
                            }}>查看</button>
                            <button onClick={(e)=>showName(e,item.name,item.age)}>查看</button>
                            </li>
                    })
                }    
            </ol>
            {
                /* 
                在react中onChange事件类似与input事件当输入框内容发生改变立即调用
                */
            }
            <input type="text" onChange={(e)=>{
                console.log(e.target.value)
            }} />
        </div>
    )
    ReactDOM.render(div,document.getElementById("root"))
</script>
</html>